home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 107_01 / newflval.c < prev    next >
Encoding:
Text File  |  1984-06-03  |  2.1 KB  |  66 lines

  1.  
  2.  
  3. /* NEWFLVAL.C a program to evaluate/test second modification
  4. of the floating point package for BDS-C.  Entry from keyboard,
  5. and diagnostic printout, etc.
  6. */
  7. #include "bdscio.h"
  8. main()
  9. {
  10.     char *atof(), op1[5], s[80];
  11.     char *fpmag(),*fpchs(),*fpasg();
  12.     char result1[5],result2[5],result3[5];
  13.     char *gets();
  14.     int atoi();
  15.     int ftoit(), ftoir();
  16.     int nin;
  17.     printf("\n");
  18.     while (TRUE) {
  19.      printf("\nEnter integer ");
  20.      gets(s);
  21.      nin = atoi(s);
  22.      itof(op1,nin);
  23.      copyout(op1);
  24.      printf("\nEnter float ");
  25.      gets(s);
  26.      atof(op1,s);
  27.      copyout(op1);
  28.     printf("\n Truncate %7d %4x Round %07d %06x ",ftoit(op1),
  29.         ftoit(op1),ftoir(op1),ftoir(op1));
  30.     fpasg(result1,op1); fpmag(result2,op1); fpchs(result3,op1);
  31.      printf("\n Assign %e  Mag %e  Chg Sign %e ",result1,
  32.         result2,result3);
  33.     printf("\n f formats %018.7f %18.8f %-18f",op1,op1,op1);
  34.             }
  35. }
  36.  
  37. copyout(oper)
  38. char oper[5];
  39. {    int i;
  40.     printf("\nFLOAT %e hex ",oper);
  41.     for(i=0;i<=4;i++) printf("%X,",oper[i]);
  42.     printf(" dec ");
  43.     for(i=0;i<=4;i++) printf("%D,",oper[i]);
  44.     printf("\n octal ");
  45.     for(i=0;i<=4;i++) printf("\\%o",oper[i]);
  46.     return;
  47. }
  48.  
  49. ┼!9∙DM═Éσ═Éσ═╤δßs#rz╖≥+!  ┴╔═Éσ═Éδßs#r═É##6#6═É~#fo┴╔┴╔$PUTCHA╥BDO╙WRIT┼=├ ├├├┼!9∙DM═É+|╡┬,!    n&σ═╤┴╔═É++|╡┬J!    n&σ!σ═╤╤┴╔═É+++|╡┬i!    n&σ!σ═╤╤┴╔═É++++|╡┬í!    n}■
  50. ┬Ä!σ!σ═╤╤!    n&σ!σ═╤╤┴╔═É##^#Vr+sz│╩╥═É^#Vr+s╒!    nδßsδ&┴╔!σ═Éσ═É~#foσ═    ╤╤╤═σ╩ⁿ!  ┴╔═É##6 #6═Éσ═
  51.         The Incredible Superpowerful 
  52.         Floating Point Package for BDS C v1.4
  53.         *************************************
  54.         software written by: Bob Mathias
  55.         this documentation by: Leor Zolman
  56.  
  57.     Components of the floating point package:
  58.  
  59.         1)    FLOAT.DOC:    This documentation file
  60.         2)    FLOAT.C:    File of support functions, written in C
  61.         3)    FP:        The workhorse function (in DEFF2.CRL)
  62.         4)  FLOATSUM.C    A Sample use of all this stuff
  63.  
  64.  EXTENDED VERSION ADDING FIVE USEFUL FUNCTIONS, USING THE V 1.44
  65.   STATIC CAPABILITY, AND ADDING THE ZERO PAD FEATURE TO _spr
  66.   (This is a further improvement of previous FLOATXT)